package com.tttare.haoyigou.manager.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
public class LoginController {

	@RequestMapping("/getName")
	public Map getName(){
		Map<String,String> map=new HashMap<String,String>();
		String name = SecurityContextHolder.getContext().getAuthentication().getName();
		//登录用户名
		map.put("name", name);
		//最后登录的时间
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
		String time = simpleDateFormat.format(new Date().getTime());
		map.put("time", time);
		return map;
	}
}
